#ifdef _WIN32

#ifndef LHC_EXCEPTIONS_WIN32_H_INCLUDED_
#define LHC_EXCEPTIONS_WIN32_H_INCLUDED_

#include "Exceptions.h"
#include "Win32Error.h"

namespace lhcutils
{

class Win32IoException : public IoException, public Win32Error
{
public:
	Win32IoException(StringPtr nonSystemMessage, DWORD errorCode);
	virtual ~Win32IoException();

	static void ThrowCorrespondingException(StringPtr nonSystemMessage, DWORD errorCode);
};

// Make sure that GetLastError is called before an expression evaluating to StringPtr nonSystemMessage
// is evaluated, possibly trashing the last eror code.
#define THROW_WIN32IO(nonSystemMessage) { DWORD lastError_ = GetLastError(); throw lhcutils::Win32IoException((nonSystemMessage), lastError_); }

#define THROW_WIN32_DERIVED_IO(nonSystemMessage) { DWORD lastError_ = GetLastError(); Win32IoException::ThrowCorrespondingException((nonSystemMessage), lastError_); }
	


class Win32AccessDeniedException : public AccessDeniedException, public Win32Error
{
private:
	DWORD m_errorCode;
public:
	Win32AccessDeniedException(StringPtr nonSystemMessage, DWORD errorCode);
	virtual ~Win32AccessDeniedException();
};

#define THROW_WIN32ACCESSDENIED(nonSystemMessage) { DWORD lastError_ = GetLastError(); throw lhcutils::Win32AccessDeniedException((nonSystemMessage), lastError_); }



class Win32FileNotFoundException : public FileNotFoundException, public Win32Error
{
public:
	Win32FileNotFoundException(StringPtr nonSystemMessage, DWORD errorCode);
	virtual ~Win32FileNotFoundException();
};

#define THROW_WIN32FILENOTFOUND(nonSystemMessage) { DWORD lastError_ = GetLastError(); throw lhcutils::Win32FileNotFoundException((nonSystemMessage), lastError_); }

}

#endif

#endif

/*
 Copyright 2011 Greg Najda

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
